home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / g_man / cat3 / widget / glwdrawingarea.z / glwdrawingarea
Text File  |  1998-10-20  |  40KB  |  661 lines

  1.  
  2.  
  3.  
  4.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa,,,, GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa ---- OOOOppppeeeennnnGGGGLLLL ddddrrrraaaawwwwiiiinnnngggg wwwwiiiiddddggggeeeettttssss....
  10.  
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           ####iiiinnnncccclllluuuuddddeeee <<<<GGGGLLLL////GGGGLLLLwwwwDDDDrrrraaaawwwwAAAA....hhhh>>>>
  14.           lllldddd ............ ----llllGGGGLLLLwwww ----llll<<<<aaaannnnyyyywwwwiiiiddddggggeeeettttlllliiiibbbbrrrraaaarrrryyyy>>>> ----llllGGGGLLLL ----llllXXXXeeeexxxxtttt ----llllXXXX11111111 ----llllXXXXmmmm
  15.           ----llllXXXXtttt ----llllmmmm
  16.  
  17.           ####iiiinnnncccclllluuuuddddeeee <<<<GGGGLLLL////GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwAAAA....hhhh>>>>
  18.           lllldddd ............ ----llllGGGGLLLLwwww ----llllGGGGLLLL ----llllXXXXeeeexxxxtttt ----llllXXXX11111111 ----llllXXXXmmmm ----llllXXXXtttt ----llllmmmm
  19.  
  20.  
  21.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  22.           GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa and GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa are widgets suitable for
  23.           OpenGL drawing.  They provide a window with the appropriate
  24.           visual and colormaps needed for OpenGL, based on supplied
  25.           parameters.  GLwDrawingArea and GLwMDrawingArea also provide
  26.           callbacks for redraw, resize, input, and initialization.
  27.  
  28.           GLwDrawingArea is not a part of any widget set, but depends
  29.           only on Xt.  GLwDrawingArea can be used with any widget set.
  30.           GLwMDrawingArea is identical to GLwDrawingArea except that
  31.           it is a subclass of the Motif widget class XmPrimitive and
  32.           has resources and defaults suitable for use with Motif.  For
  33.           example, GLwMDrawingArea provides the default Motif
  34.           background and foreground colors for resources, and deals
  35.           better with keyboard traversal.  Although the GLwDrawingArea
  36.           widget can be used in a Motif program, it is recommended
  37.           that GLwMDrawingArea be used instead.
  38.  
  39.           Since both GLwDrawingArea and GLwMDrawingArea widgets behave
  40.           almost identically, the remainder of this manual page will
  41.           refer only to GLwDrawingArea, except when the behaviors
  42.           differ.  Unless explicitly stated, all statements about
  43.           GLwDrawingArea also apply to GLwMDrawingArea.
  44.  
  45.           Among the information provided when creating a
  46.           GLwDrawingArea is information necessary to determine the
  47.           visual.  This may be provided in three ways, all of them
  48.           through resources.  A specific visualInfo structure may be
  49.           passed in.  (This visualInfo must have been obtained
  50.           elsewhere; it is the application designer's responsibility
  51.           to make sure that it is compatible with the OpenGL rendering
  52.           done by the application).  Alternatively, an attribute list
  53.           may be provided.  This attribute list is formatted
  54.           identically to that used for direct open GL programming.
  55.           Finally, each attribute can be specified as an individual
  56.           resource.  The latter method is the simplest, and is the
  57.           only method that works from resource files.
  58.  
  59.           In addition to allocating the visual, the GLwDrawingArea
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 4/30/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  71.  
  72.  
  73.  
  74.           will also allocate the colormap unless one is provided by
  75.           the application.  (If one is provided it is the application
  76.           writer's responsibility to guarantee compatibility between
  77.           the colormap and the visual).  If an application creates
  78.           multiple GLwDrawingAreas with the same visual, the same
  79.           colormap will be used.  (However the colormap will not be
  80.           shared among separate applications).
  81.  
  82.           Creating the widget does not actually create the window
  83.           until it is realized, and consequently, the application
  84.           should not perform any OpenGL operations to the window
  85.           immediately after creation.  Instead the application must
  86.           wait until after it has realized the window.  Alternatively,
  87.           the ggggiiiinnnniiiitttt callback may be used to indicate when the window
  88.           has been created.  Upon receiving this callback, the
  89.           application can perform all OpenGL initialization for the
  90.           window, and can subsequently perform other operations on it.
  91.           The initialization is discussed in more detail below.
  92.  
  93.           Applications select which GLwDrawingArea they are accessing
  94.           using either _g_l_X_M_a_k_e_C_u_r_r_e_n_t or the convenience function
  95.           _G_L_w_D_r_a_w_i_n_g_A_r_e_a_M_a_k_e_C_u_r_r_e_n_t which uses a widget instead of a
  96.           display and window.  If there is only one GLwDrawingArea
  97.           this need only be called once, however if there is more than
  98.           one GLwDrawingArea it should be called at the start of each
  99.           callback.  Callbacks in this case include not only callbacks
  100.           provided by the widget itself, but any other callback that
  101.           leads to GL activity such as a timeout or a workproc.
  102.  
  103.           If an application is using double buffering, it may call
  104.           _G_L_w_D_r_a_w_i_n_g_A_r_e_a_S_w_a_p_B_u_f_f_e_r_s instead of glXSwapBuffers.  This
  105.           allows the use of the widget instead of the display and
  106.           window.
  107.  
  108.         GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa CCCCllllaaaasssssssseeeessss
  109.           GLwDrawingArea inherits behavior and resources from the CCCCoooorrrreeee
  110.           class.
  111.           The class pointer is GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaWWWWiiiiddddggggeeeettttCCCCllllaaaassssssss.
  112.           The class name is GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa.
  113.  
  114.         GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa CCCCllllaaaasssssssseeeessss
  115.           GLwMDrawingArea inherits behavior and resources from the
  116.           XXXXmmmmPPPPrrrriiiimmmmiiiittttiiiivvvveeee and CCCCoooorrrreeee classes.
  117.           The class pointer is ggggllllwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaWWWWiiiiddddggggeeeettttCCCCllllaaaassssssss.
  118.           The class name is GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa.
  119.  
  120.  
  121.         NNNNeeeewwww RRRReeeessssoooouuuurrrrcccceeeessss
  122.           The following tables define a set of widget resources used
  123.           by the programmer to specify data.  The programmer can also
  124.           set the resource values for the inherited classes to set
  125.           attributes for this widget.  To reference a resource by name
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 4/30/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  137.  
  138.  
  139.  
  140.           or by class in a .Xdefaults file, remove the GGGGLLLLwwwwNNNN or GGGGLLLLwwwwCCCC
  141.           prefix and use the remaining letters.  There are two tables
  142.           included.  The first table includes resources that
  143.           correspond directly to the attributes used by
  144.           _g_l_X_C_h_o_o_s_e_V_i_s_u_a_l.  As with _g_l_X_C_h_o_o_s_e_V_i_s_u_a_l, all Boolean
  145.           resources default to FALSE and all integer resources default
  146.           to 0, except redSize, greenSize and blueSize which default
  147.           to 1.  These resources can all be set only at creation time,
  148.           and are used to determine the visual.  If either the
  149.           _G_L_w_N_a_t_t_r_i_b_L_i_s_t or _G_L_w_N_v_i_s_u_a_l_I_n_f_o resource is set, these
  150.           resources are ignored.  The specific meaning of these
  151.           resources is discussed in the _g_l_X_C_h_o_o_s_e_V_i_s_u_a_l manual page
  152.           and will not be discussed here.
  153.  
  154.      __________________________________________________________________________
  155.     | NNNNaaaammmmeeee              |  CCCCllllaaaassssssss             |  TTTTyyyyppppeeee   |  OOOOppppeeeennnnGGGGLLLL aaaattttttttrrrriiiibbbbuuuutttteeee    |
  156.     |____________________|_____________________|__________|_______________________|
  157.     | GLwNbufferSize    |  GLwCBufferSize    |  int    |  GLX_BUFFER_SIZE     |
  158.     |____________________|_____________________|__________|_______________________|
  159.     | GLwNlevel         |  GLwCLevel         |  int    |  GLX_LEVEL           |
  160.     |____________________|_____________________|__________|_______________________|
  161.     | GLwNrgba          |  GLwCRgba          |  Boolean|  GLX_RGBA            |
  162.     |____________________|_____________________|__________|_______________________|
  163.     | GLwNdoublebuffer  |  GLwCDoublebuffer  |  Boolean|  GLX_DOUBLEBUFFER    |
  164.     |____________________|_____________________|__________|_______________________|
  165.     | GLwNstereo        |  GLwCStereo        |  Boolean|  GLX_STEREO          |
  166.     |____________________|_____________________|__________|_______________________|
  167.     | GLwNauxBuffers    |  GLwCAuxBuffers    |  Boolean|  GLX_AUX_BUFFERS     |
  168.     |____________________|_____________________|__________|_______________________|
  169.     | GLwNredSize       |  GLwCColorSize     |  int    |  GLX_RED_SIZE        |
  170.     |____________________|_____________________|__________|_______________________|
  171.     | GLwNgreenSize     |  GLwCColorSize     |  int    |  GLX_GREEN_SIZE      |
  172.     |____________________|_____________________|__________|_______________________|
  173.     | GLwNblueSize      |  GLwCColorSize     |  int    |  GLX_BLUE_SIZE       |
  174.     |____________________|_____________________|__________|_______________________|
  175.     | GLwNalphaSize     |  GLwCAlphaSize     |  int    |  GLX_ALPHA_SIZE      |
  176.     |____________________|_____________________|__________|_______________________|
  177.     | GLwNdepthSize     |  GLwCDepthSize     |  int    |  GLX_DEPTH_SIZE      |
  178.     |____________________|_____________________|__________|_______________________|
  179.     | GLwNstencilSize   |  GLwCStencilSize   |  int    |  GLX_STENCIL_SIZE    |
  180.     |____________________|_____________________|__________|_______________________|
  181.     | GLwNaccumRedSize  |  GLwCAccumColorSize|  int    |  GLX_ACCUM_RED_SIZE  |
  182.     |____________________|_____________________|__________|_______________________|
  183.     | GLwNaccumGreenSize|  GLwCAccumColorSize|  int    |  GLX_ACCUM_GREEN_SIZE|
  184.     |____________________|_____________________|__________|_______________________|
  185.     | GLwNaccumBlueSize |  GLwCAccumColorSize|  int    |  GLX_ACCUM_BLUE_SIZE |
  186.     |____________________|_____________________|__________|_______________________|
  187.     | GLwNaccumAlphaSize|  GLwCAccumAlphaSize|  int    |  GLX_ACCUM_ALPHA_SIZE|
  188.     |____________________|_____________________|__________|_______________________|
  189.  
  190.  
  191.           The following table lists other resources of the
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 4/30/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  203.  
  204.  
  205.  
  206.           GLwDrawingArea widget.  each of these will be described
  207.           subsequently.  The codes in the access column indicate if
  208.           the given resource can be set at creation time (CCCC), set by
  209.           using XXXXttttSSSSeeeettttVVVVaaaalllluuuueeeessss (SSSS), retrieved by using XXXXttttGGGGeeeettttVVVVaaaalllluuuueeeessss (GGGG),
  210.           or is not applicable (NNNN////AAAA).
  211.  
  212.      NNNNaaaammmmeeee                      CCCCllllaaaassssssss                   TTTTyyyyppppeeee             DDDDeeeeffff    AAAAcccccccc
  213.      _____________________________________________________________________________
  214.      GLwNallocateBackground    GLwCAllocateColors      Boolean          F      CG
  215.      GLwNallocateOtherColors   GLwCAllocateColors      Boolean          F      CG
  216.      GLwNattribList            GLwCAttribList          int *            NULL   CG
  217.      GLwNexposeCallback        GLwCCallback            XtCallbackList   NULL   C
  218.      GLwNginitCallback         GLwCCallback            XtCallbackList   NULL   C
  219.      GLwNinputCallback         GLwCCallback            XtCallbackList   NULL   C
  220.      GLwNinstallBackground     GLwCInstallBackground   Boolean          T      CG
  221.      GLwNinstallColormap       GLwCInstallColormap     Boolean          T      CG
  222.      GLwNresizeCallback        GLwCCallback            XtCallbackList   NULL   C
  223.      GLwNvisualInfo            GLwCVisualInfo          XVisualInfo*     NULL   CG
  224.  
  225.  
  226.           GGGGLLLLwwwwNNNNaaaallllllllooooccccaaaatttteeeeBBBBaaaacccckkkkggggrrrroooouuuunnnndddd
  227.                If TRUE, the background pixel and pixmap will be
  228.                allocated if appropriate using the newly calculated
  229.                colormap and visual.  If FALSE, they will retain values
  230.                calculated using the parent's colormap and visual.
  231.                Applications which wish to have X clear their
  232.                background for them will usually set this to TRUE.
  233.                Applications clearing their own background will often
  234.                set this to FALSE, although they may set this to TRUE
  235.                if they query the background for their own use.  One
  236.                reason to leave this resource FALSE is that if color
  237.                index mode is in use this avoid using up a pixel from
  238.                the newly allocated colormap.  Also, on hardware that
  239.                supports only one colormap, the application may need to
  240.                do more careful color allocation to avoid flashing
  241.                between the openGL colormap and the default X colormap.
  242.                (Note that because of the way Xt works, the background
  243.                colors are originally calculated using the default
  244.                colormap; if this resource is set they can be
  245.                recalculated correctly.  If a colormap was explicitly
  246.                supplied to the widget rather than being dynamically
  247.                calculated, these resources are always calculated using
  248.                that colormap.)
  249.  
  250.           GGGGLLLLwwwwNNNNaaaallllllllooooccccaaaatttteeeeOOOOtttthhhheeeerrrrCCCCoooolllloooorrrrssss
  251.                This is similar to GGGGLLLLwwwwNNNNaaaallllllllooooccccaaaatttteeeeBBBBaaaacccckkkkggggrrrroooouuuunnnndddd, but
  252.                allocates other colors normally allocated by widgets.
  253.                Although the GLwDrawingArea and GLwMDrawingArea widget
  254.                do not make use of these colors the application may
  255.                choose to query them.  For the non-Motif GLwDrawingArea
  256.                widget there are no other colors allocated, so this
  257.                resource is a no-op.  For the Motif GLwMDrawingArea are
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 4/30/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  269.  
  270.  
  271.  
  272.                widget, the XmPrimitive resources XXXXmmmmNNNNffffoooorrrreeeeggggrrrroooouuuunnnndddd,
  273.                XXXXmmmmNNNNhhhhiiiigggghhhhlllliiiigggghhhhttttCCCCoooolllloooorrrr, and XXXXmmmmNNNNhhhhiiiigggghhhhlllliiiigggghhhhttttPPPPiiiixxxxmmmmaaaapppp are
  274.                calculated.
  275.  
  276.           GGGGLLLLwwwwNNNNaaaattttttttrrrriiiibbbbLLLLiiiisssstttt
  277.                Contains the list of attributes suitable for a call to
  278.                _g_l_X_C_h_o_o_s_e_V_i_s_u_a_l.  If this resource is NULL, it is
  279.                calculated based on the attribute resources.  If it is
  280.                not NULL, the attribute resources are ignored.
  281.  
  282.           GGGGLLLLwwwwNNNNeeeexxxxppppoooosssseeeeCCCCaaaallllllllbbbbaaaacccckkkk
  283.                Specifies the list of callbacks that is called when the
  284.                widget receives an exposure event.  The callback reason
  285.                is GGGGLLLLwwwwCCCCRRRR____EEEEXXXXPPPPOOOOSSSSEEEE.  The callback structure also includes
  286.                the exposure event.  The application will generally
  287.                want to redraw the scene.
  288.  
  289.           GGGGLLLLwwwwNNNNggggiiiinnnniiiittttCCCCaaaallllllllbbbbaaaacccckkkk
  290.                Specifies the list of callbacks that is called when the
  291.                widget is first realized.  Since no OpenGL operations
  292.                can be done before the widget is realized, this
  293.                callback can be used to perform any appropriate OpenGL
  294.                initialization such as creating a context.  The
  295.                callback reason is GGGGLLLLwwwwCCCCRRRR____GGGGIIIINNNNIIIITTTT.
  296.  
  297.           GGGGLLLLwwwwNNNNiiiinnnnppppuuuuttttCCCCaaaallllllllbbbbaaaacccckkkk
  298.                Specifies the list of callbacks that is called when the
  299.                widget receives a keyboard or mouse event.  By default,
  300.                the input callback is called on each key press and key
  301.                release, on each mouse button press and release, and
  302.                whenever the mouse is moved while a button is pressed.
  303.                However this can be changed by providing a different
  304.                translation table. The callback structure also includes
  305.                the input event.  The callback reason is GGGGLLLLwwwwCCCCRRRR____IIIINNNNPPPPUUUUTTTT.
  306.  
  307.                The input callback is provided as a programming
  308.                convenience, as it provides a convenient way to catch
  309.                all input events.  However, a more modular program can
  310.                often be obtained by providing specific actions and
  311.                translations in the application rather than using a
  312.                single catch all callback.  Use of explicit
  313.                translations can also provide for more customizability.
  314.  
  315.           GGGGLLLLwwwwNNNNiiiinnnnssssttttaaaallllllllBBBBaaaacccckkkkggggrrrroooouuuunnnndddd
  316.                If set to TRUE, the background is installed on the
  317.                window.  If set to FALSE, the window has no background.
  318.                This resource has no effect unless
  319.                GGGGLLLLwwwwNNNNaaaallllllllooooccccaaaatttteeeeBBBBaaaacccckkkkggggrrrroooouuuunnnndddd is also TRUE.
  320.  
  321.           GGGGLLLLwwwwNNNNiiiinnnnssssttttaaaallllllllCCCCoooolllloooorrrrmmmmaaaapppp
  322.                If set to TRUE, the widget will call
  323.                _X_S_e_t_W_M_C_o_l_o_r_m_a_p_W_i_n_d_o_w_s to tell the window manager to
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 4/30/98)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  335.  
  336.  
  337.  
  338.                install the colormap when the window's shell has focus.
  339.                If set to FALSE, this will not be called.  For
  340.                applications with multiple GLwDrawingAreas sharing a
  341.                single colormap, it is most efficient to set this
  342.                resource to TRUE for exactly one GLwDrawingArea with
  343.                each colormap.  If an application needs additional
  344.                control over the order of colormaps, this resource can
  345.                be set to FALSE, with the application calling
  346.                _X_S_e_t_W_M_C_o_l_o_r_m_a_p_W_i_n_d_o_w_s explicitly.
  347.  
  348.           GGGGLLLLwwwwNNNNrrrreeeessssiiiizzzzeeeeCCCCaaaallllllllbbbbaaaacccckkkk
  349.                Specifies the list of callbacks that is called when the
  350.                GLwDrawingArea is resized.  The callback reason is
  351.                GGGGLLLLwwwwCCCCRRRR____RRRREEEESSSSIIIIZZZZEEEE.
  352.  
  353.           GGGGLLLLwwwwNNNNvvvviiiissssuuuuaaaallllIIIInnnnffffoooo
  354.                Contains a pointer to the window's visual info
  355.                structure.  If NULL, the visualInfo is calculated at
  356.                widget creation time based on the _G_L_w_N_a_t_t_r_i_b_u_t_e_L_i_s_t
  357.                resource (which is itself calculated from the various
  358.                resources).  If GGGGLLLLwwwwNNNNvvvviiiissssuuuuaaaallllIIIInnnnffffoooo is not NULL the
  359.                _G_L_w_N_a_t_t_r_i_b_u_t_L_i_s_t and the attribute resources are
  360.                ignored.
  361.  
  362.  
  363.         IIIInnnnhhhheeeerrrriiiitttteeeedddd RRRReeeessssoooouuuurrrrcccceeeessss
  364.           Both GLwDrawingArea and GLwMDrawingArea inherit behavior and
  365.            resources from the core superclass.  Other than the
  366.           behavior of the colormap and background resources described
  367.           previously, all defaults are the same as for core.
  368.  
  369.           In addition, the Motif version GLwMDrawingArea also inherits
  370.           from XmPrimitive.  The behavior of the color resources has
  371.           been described previously.  The _T_r_a_v_e_r_s_a_l_O_n resource is
  372.           disabled for this widget, but if keyboard input is required
  373.           it should be enabled.  (Also, the application should call
  374.           XXXXmmmmPPPPrrrroooocccceeeessssssssTTTTrrrraaaavvvveeeerrrrssssaaaallll((((wwwwiiiiddddggggeeeetttt,,,, XXXXmmmmTTTTRRRRAAAAVVVVEEEERRRRSSSSEEEE____CCCCUUUURRRRRRRREEEENNNNTTTT)))) whenever
  375.           mouse button 1 is clicked in the widget.  This is similar to
  376.           the requirements of the Motif Drawing area.)  Because Motif
  377.           gets confused by having multiple visuals in one top level
  378.           shell, XXXXmmmmNNNNhhhhiiiigggghhhhlllliiiigggghhhhttttOOOOnnnnEEEEnnnntttteeeerrrr has been disabled, and
  379.           XXXXmmmmNNNNhhhhiiiigggghhhhlllliiiigggghhhhttttTTTThhhhiiiicccckkkknnnneeeessssssss has been set to 0.
  380.  
  381.         CCCCaaaallllllllbbbbaaaacccckkkk IIIInnnnffffoooorrrrmmmmaaaattttiiiioooonnnn
  382.           A pointer to the following structure is passed to each
  383.           callback:
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                          (printed 4/30/98)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  401.  
  402.  
  403.  
  404.           ttttyyyyppppeeeeddddeeeeffff ssssttttrrrruuuucccctttt
  405.           {
  406.             iiiinnnntttt      _r_e_a_s_o_n;
  407.             XXXXEEEEvvvveeeennnntttt   * _e_v_e_n_t;
  408.             DDDDiiiimmmmeeeennnnssssiiiioooonnnn_w_i_d_t_h, _h_e_i_g_h_t;
  409.           } GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaCCCCaaaallllllllbbbbaaaacccckkkkSSSSttttrrrruuuucccctttt;
  410.  
  411.  
  412.           _r_e_a_s_o_n Indicates why the callback was invoked.  Appropriate
  413.                  values are stated in the above resource descriptions.
  414.                  For Motif programmers, the values GGGGLLLLwwwwCCCCRRRR____EEEEXXXXPPPPOOOOSSSSEEEE,
  415.                  GGGGLLLLwwwwCCCCRRRR____RRRREEEESSSSIIIIZZZZEEEE, and GGGGLLLLwwwwCCCCRRRR____IIIINNNNPPPPUUUUTTTT are equal to
  416.                  XXXXmmmmCCCCRRRR____EEEEXXXXPPPPOOOOSSSSEEEE, XXXXmmmmCCCCRRRR____RRRREEEESSSSIIIIZZZZEEEE, and XXXXmmmmCCCCRRRR____IIIINNNNPPPPUUUUTTTT
  417.                  respectively.  GGGGLLLLwwwwCCCCRRRR____GGGGIIIINNNNIIIITTTT does not have a Motif
  418.                  equivalent.
  419.  
  420.           _e_v_e_n_t  Points to the XXXXEEEEvvvveeeennnntttt that triggered the callback.
  421.                  This is NULL for GGGGLLLLwwwwNNNNggggiiiinnnniiiittttCCCCaaaallllllllbbbbaaaacccckkkk aaaannnndddd
  422.                  GGGGLLLLwwwwNNNNrrrreeeessssiiiizzzzeeeeCCCCaaaallllllllbbbbaaaacccckkkk....
  423.  
  424.           _w_i_d_t_h aaaannnndddd _h_e_i_g_h_t
  425.                  Are set to the width and height of the window.
  426.  
  427.  
  428.         TTTTrrrraaaannnnssssllllaaaattttiiiioooonnnnssss
  429.           GLwDrawingArea has the translations listed below.
  430.  
  431.           <<<<KKKKeeeeyyyyDDDDoooowwwwnnnn>>>>::::     ggggllllwwwwIIIInnnnppppuuuutttt(((())))
  432.           <<<<KKKKeeeeyyyyUUUUpppp>>>>::::       ggggllllwwwwIIIInnnnppppuuuutttt(((())))
  433.           <<<<BBBBttttnnnnDDDDoooowwwwnnnn>>>>::::     ggggllllwwwwIIIInnnnppppuuuutttt(((())))
  434.           <<<<BBBBttttnnnnUUUUpppp>>>>::::       ggggllllwwwwIIIInnnnppppuuuutttt(((())))
  435.           <<<<BBBBttttnnnnMMMMoooottttiiiioooonnnn>>>>::::   ggggllllwwwwIIIInnnnppppuuuutttt(((())))
  436.  
  437.           GLwMDrawingArea has the following additional translation:
  438.  
  439.           <<<<KKKKeeeeyyyy>>>>oooossssffffHHHHeeeellllpppp::::  PPPPrrrriiiimmmmiiiittttiiiivvvveeeeHHHHeeeellllpppp(((())))
  440.  
  441.           An application wishing to catch other events than these
  442.           defaults can do so by installing a different translation
  443.           table.
  444.  
  445.  
  446.  
  447.         AAAAccccttttiiiioooonnnn RRRRoooouuuuttttiiiinnnneeeessss
  448.           The GLwDrawingArea has the following action routine:
  449.  
  450.           ggggllllwwwwIIIInnnnppppuuuutttt(((()))):
  451.                Called whenever one of the above translations specifies
  452.                that input has occurred.  Its sole purpose is to call
  453.                the input callback.
  454.  
  455.  
  456.  
  457.  
  458.  
  459.      Page 7                                          (printed 4/30/98)
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  467.  
  468.  
  469.  
  470.      IIIINNNNIIIITTTTIIIIAAAALLLLIIIIZZZZAAAATTTTIIIIOOOONNNN
  471.           When the widget is initially created (e.g. through
  472.           XXXXttttCCCCrrrreeeeaaaatttteeeeWWWWiiiiddddggggeeeetttt((((3333XXXX))))) the associated window is not actually
  473.           created.  Instead, window creation is delayed until the
  474.           widget is realized.  However, _g_l_X_c_h_o_o_s_e_V_i_s_u_a_l is called
  475.           immediately, so information based on its results is
  476.           available.
  477.  
  478.           Between the time the widget is created and it is realized,
  479.           the following apply:
  480.  
  481.           +o    No OpenGL operations can be done to the window
  482.  
  483.           +o    No resize callbacks are generated.
  484.  
  485.           +o    The normal window is available (XtWindow returns NULL).
  486.  
  487.           +o    _G_L_w_D_r_a_w_i_n_g_A_r_e_a_M_a_k_e_C_u_r_r_e_n_t (and _g_l_X_M_a_k_e_C_u_r_r_e_n_t) should
  488.                not be called.
  489.  
  490.           When the widget is realized, the following actions take
  491.           place:
  492.  
  493.           +o    The window is created.
  494.  
  495.           +o    The ggggiiiinnnniiiitttt callback is called.  The user may use this
  496.                callback to perform any needed OpenGL initialization to
  497.                the window.
  498.  
  499.  
  500.      NNNNOOOOTTTTEEEESSSS
  501.           When using the input callback to receive keyboard input, the
  502.           keycode in the event must be converted to a KeySym.  Use
  503.           XXXXLLLLooooooookkkkuuuuppppKKKKeeeeyyyyssssyyyymmmm((((3333XXXX)))) or XXXXLLLLooooooookkkkuuuuppppSSSSttttrrrriiiinnnngggg((((3333XXXX)))) to do the conversion.
  504.           Keyboard input can also be dealt using translations, in
  505.           which case no such conversion is required.
  506.  
  507.           Motif programmers should keep in mind that OSF uses virtual
  508.           bindings and replaces some of the key bindings.  As a common
  509.           example, if the ESC key is to be used to exit the program
  510.           (as it often is in GL programs), the translation should
  511.           specify <key>osfCancel instead of <key>Escape.
  512.  
  513.           Motif programmers may also create a GLwMDrawingArea widget
  514.           with the Motif style GGGGLLLLwwwwCCCCrrrreeeeaaaatttteeeeMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa.
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.      Page 8                                          (printed 4/30/98)
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  533.  
  534.  
  535.  
  536.      EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  537.           Here are some code fragments that create a GLwDrawingArea
  538.           widget, and manage the appropriate callbacks.
  539.  
  540.  
  541.              #include <X11/GLW/GLwDrawingArea.h>
  542.              static GLXContext glx_context;  /* assume only one context */
  543.              . . .
  544.  
  545.              main()
  546.              {
  547.                  Arg args[10];
  548.                  int n;
  549.  
  550.                  Widget parent;/* The parent of the gl widget */
  551.                  Widget glw;/* The GLwDrawingArea widget          */
  552.                  . . .
  553.  
  554.                  /* Create the widget using RGB mode.  This can also be set
  555.                   * in an X Defaults file
  556.                   */
  557.                  n = 0;
  558.                  XtSetArg(args[n], GLwNrgba, TRUE); n++;
  559.                  glw = XtCreateManagedWidget("glw", GLwDrawingAreaWidgetClass,
  560.                             parent, args, n);
  561.                  XtAddCallback(glw, GLwNexposeCallback, exposeCB, 0);
  562.                  XtAddCallback(glw, GLwNresizeCallback, resizeCB, 0);
  563.                  XtAddCallback(glw, GLwNginitCallback, ginitCB, 0);
  564.                  /* Also add input callback if needed */
  565.                  . . .
  566.              }
  567.  
  568.              static void
  569.              exposeCB(Widget w, XtPointer client_data,
  570.                        (GLwDrawingAreaCallbackStruct *)call_data)
  571.              {
  572.                  GLwDrawingAreaMakeCurrent (w, glx_context);
  573.                  /* redraw the display */
  574.              }
  575.  
  576.              static void
  577.              resizeCB(Widget w, XtPointer client_data,
  578.                        (GLwDrawingAreaCallbackStruct *)call_data)
  579.              {
  580.                  GLwDrawingAreaMakeCurrent (w, glx_context);
  581.                  /* perform any resize actions */
  582.              }
  583.  
  584.              static void
  585.              ginitCB(Widget w, XtPointer client_data,
  586.                        (GLwDrawingAreaCallbackStruct *)call_data)
  587.              {
  588.  
  589.  
  590.  
  591.      Page 9                                          (printed 4/30/98)
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.      GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))        UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV        GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa((((3333XXXX))))
  599.  
  600.  
  601.  
  602.                  Arg args[1];
  603.                  XVisualInfo *vi;
  604.  
  605.                  XtSetArg(args[0], GLwNvisualInfo, &vi);
  606.                  XtGetValues(w, args, 1);
  607.  
  608.                  /* create a visual context */
  609.                  glx_context = glXCreateContext(XtDisplay(w), vi, 0, GL_FALSE);
  610.                  GLwDrawingAreaMakeCurrent (w, glx_context);
  611.                  /* Perform any necessary graphics initialization.*/
  612.              }
  613.  
  614.  
  615.           The Motif program need only differ by including
  616.           GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa....hhhh instead of GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaa....hhhh and by
  617.           creating a widget of type GGGGLLLLwwwwMMMMDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaWWWWiiiiddddggggeeeettttCCCCllllaaaassssssss instead
  618.           of GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaWWWWiiiiddddggggeeeettttCCCCllllaaaassssssss.  As an alternative, the Motif
  619.           program could use GGGGLLLLwwwwCCCCrrrreeeeaaaatttteeeeMMMMDDDDrrrraaaawwww((((3333XXXX)))) instead.
  620.  
  621.  
  622.      WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  623.           If a GLwDrawingArea widget is created as a child of an
  624.           already realized widget, the GLwDrawingArea widget will be
  625.           created immediately, without giving the user an opportunity
  626.           to add the ggggiiiinnnniiiitttt callback.  In such a case, initialization
  627.           should be done immediately after creating the widget rather
  628.           than by using the callback.
  629.  
  630.           If the non-Motif GLwDrawingArea widget is used in a Motif
  631.           program and keyboard traversal is attempted, the behavior is
  632.           undefined if the user traverses into the GLwDrawingArea
  633.           widget.
  634.  
  635.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  636.           ggggllllXXXXCCCChhhhoooooooosssseeeeVVVViiiissssuuuuaaaallll, GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnntttt, ggggllllXXXXMMMMaaaakkkkeeeeCCCCuuuurrrrrrrreeeennnntttt,
  637.           GGGGLLLLwwwwDDDDrrrraaaawwwwiiiinnnnggggAAAArrrreeeeaaaaSSSSwwwwaaaappppBBBBuuuuffffffffeeeerrrrssss GGGGLLLLwwwwCCCCrrrreeeeaaaatttteeeeMMMMDDDDrrrraaaawwww, CCCCoooorrrreeee((((3333XXXX)))),
  638.           XXXXmmmmPPPPrrrriiiimmmmiiiittttiiiivvvveeee((((3333XXXX)))), VVVViiiirrrrttttuuuuaaaallllBBBBiiiinnnnddddiiiinnnnggggssss((((3333XXXX)))), GGGGfffflllluuuusssshhhh((((3333GGGG)))),
  639.           XXXXSSSSeeeettttWWWWMMMMCCCCoooolllloooorrrrmmmmaaaappppWWWWiiiinnnnddddoooowwwwssss((((3333XXXX11111111)))) and the OpenGL spec.
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.      Page 10                                         (printed 4/30/98)
  658.  
  659.  
  660.  
  661.